﻿Imports System.Collections
Imports System.Collections.Generic

Partial Public Class Helper
    ''' <summary>
    ''' Using Generics to retrun a Strongly Typed List
    ''' </summary>
    ''' <typeparam name="T"></typeparam>
    ''' <param name="list"></param>
    ''' <returns></returns>
    Public Function ToListOf(Of T)(ByVal list As IList) As List(Of T)
        If list Is Nothing Then
            Return Nothing
        End If
        Dim TempList As New ArrayList(list)
        Return New List(Of T)(TryCast(TempList.ToArray(GetType(T)), T()))
    End Function
End Class